package com.zy.dao.impl;

import com.zy.dao.AddShopDao;
import com.zy.utils.JdbcUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class AddShopDaoImpl implements AddShopDao {
    @Override
    public boolean insertShop(String name, String imageUrl, double price, String contactPerson, String contactNumber) {
        String sql = "INSERT INTO tb_shops (name, image_url, price, contact_person, contact_number) VALUES (?, ?, ?, ?, ?)";
        try (Connection connection = JdbcUtil.getConnection();
             PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
            preparedStatement.setString(1, name);
            preparedStatement.setString(2, imageUrl);
            preparedStatement.setDouble(3, price);
            preparedStatement.setString(4, contactPerson);
            preparedStatement.setString(5, contactNumber);
            int rowsAffected = preparedStatement.executeUpdate();
            return rowsAffected > 0;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }
}
